home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / dvivga9.zip / DVIVGA.C < prev    next >
C/C++ Source or Header  |  1988-10-22  |  17KB  |  619 lines

  1. /* latest revision Oct. 18, 1988 by JDM
  2.  
  3.  
  4.  
  5. /* -*-C-*- dvivga.c */
  6. /*-->dvivga*/
  7. /**********************************************************************/
  8. /******************************* dvivga *******************************/
  9. /**********************************************************************/
  10. #include "dvihead.h"
  11.  
  12.  
  13. /**********************************************************************/
  14. /************************  Device Definitions  ************************/
  15. /**********************************************************************/
  16.  
  17. /* All output-device-specific definitions go here.  This section must
  18. be changed when modifying a dvi driver for use on a new device */
  19.  
  20.  
  21. #undef  DEBUG
  22. #define DEBUG 1
  23. #undef   VGASCREEN
  24. #define  VGASCREEN       1        /* conditional compilation flag */
  25.  
  26.  
  27.  
  28.  
  29. #undef HIRES
  30. #define  HIRES          0        /* this is 72 dpi version  */
  31.  
  32. #define VERSION_NO    "2.10"        /* DVI driver version number */
  33.  
  34. #define  DEVICE_ID    "VGA Screen Previewer"
  35.                     /* this string is printed at runtime */
  36. #define OUTFILE_EXT    "vga"
  37.  
  38. #define  BYTE_SIZE        8        /* output file byte size */
  39.  
  40. #undef STDRES
  41. #define STDRES  0            /* 0 for low-resolution devices */
  42.  
  43. #define  XDPI           72
  44. #define  XPSIZE        8        /* horizontal paper size in inches */
  45. #define  XSIZE          640
  46. #define  YPSIZE         14
  47.  
  48.                     /* 2*HOST_WORD_SIZE */
  49.  
  50.  
  51.  
  52. #define  XWORDS        ((XSIZE + HOST_WORD_SIZE - 1)/HOST_WORD_SIZE)
  53.                     /* number of words in rows  */
  54.                     /* of bitmap array */
  55.  
  56. #define  YDPI        XDPI        /* vertical dots/inch */
  57. #define  YSIZE        (YDPI*YPSIZE)    /* number of vertical dots */
  58.  
  59. /* The printer bit map. */
  60.  
  61. #define XBIT XWORDS
  62. #define YBIT YSIZE
  63.  
  64. #undef  SEGMEM
  65. #define SEGMEM 1 
  66.  
  67. #define  MINM  0
  68.  
  69. int      firstlinepage, brokenprtpage;
  70. int      neednewpage, neednewbmap;
  71. double   newmagfact;
  72. int      first_picture = TRUE;
  73. int      maxm, nlines, oldvmode, displaycode ;
  74.  
  75. #include <bios.h>
  76. #include <dos.h>
  77. #include <conio.h>
  78.  
  79. UNSIGN32* bitmap[YBIT+1] =
  80. {
  81.     (UNSIGN32*)NULL    /* only first entry need be initialized */
  82. };
  83. #define BITMAP(y,x) (bitmap[y] + (UNSIGN16)(x))
  84.  
  85.  
  86. #include "main.h"
  87. #undef STDMAG
  88. #define STDMAG 550
  89.  
  90. #include "abortrun.h"
  91. #include "actfact.h"
  92. #include "alldone.h"
  93. #include "chargf.h"
  94. #include "charpk.h"
  95. #include "charpxl.h"
  96. #include "clrbmap.h"
  97. #include "clrrow.h"
  98. #include "dbgopen.h"
  99.  
  100. int  far        exfn();
  101.  
  102.  
  103. int far exfn()
  104. {
  105.     devterm();
  106.     exit(1);
  107. }
  108.  
  109.  
  110. /*-->devinit*/
  111. /**********************************************************************/
  112. /****************************** devinit *******************************/
  113. /**********************************************************************/
  114.  
  115. void
  116. devinit(argc,argv)        /* initialize device */
  117. int argc;
  118. char *argv[];
  119. {
  120.     (void)getbmap();
  121.  
  122. }
  123.  
  124. /*-->devterm*/
  125. /**********************************************************************/
  126. /****************************** devterm *******************************/
  127. /**********************************************************************/
  128.  
  129. void
  130. devterm()            /* terminate device */
  131. {
  132.    union REGS rg;
  133.    rg.x.ax = oldvmode;
  134.    if(!first_picture)int86(16,&rg,&rg);
  135. }
  136.  
  137. #include "dispchar.h"
  138. #include "dvifile.h"
  139. #include "dviinit.h"
  140. #include "dviterm.h"
  141. #include "fatal.h"
  142. #include "fillrect.h"
  143. #include "findpost.h"
  144. #include "fixpos.h"
  145. #include "fontfile.h"
  146. #include "fontsub.h"
  147.  
  148. void
  149. getbmap()                /* allocate bitmap array */
  150. {
  151.  
  152. static unsigned long huge basebit[ (long)XBIT * (long)(YBIT+2)];
  153. unsigned long *ibit;
  154. unsigned long i, j, k;
  155. unsigned y;
  156.     if (bitmap[0] == (UNSIGN32*)NULL) {
  157.  
  158.         for (y = 0; y <= (UNSIGN16)YBIT; ++y)
  159.         {
  160.             ibit = (unsigned long *) &basebit[ y  * XBIT ];
  161.                    /* UGH! fix up pointers to avoid segment overlap */
  162.             i = (unsigned long)ibit & (unsigned long)4;
  163.             j = (unsigned long)ibit & (unsigned long) 0x0000fff0L;
  164.             k = (unsigned long)ibit & (unsigned long) 0xffff0000L;
  165.             i += k + (j << 12);
  166.             bitmap[y] = (UNSIGN32*) i;
  167.         }
  168.     }
  169. }
  170.  
  171.  
  172.  
  173.  
  174. #include "getbytes.h"
  175. #include "getfntdf.h"
  176. #include "getpgtab.h"
  177. #include "inch.h"
  178. #include "initglob.h"
  179. #include "loadchar.h"
  180.  
  181. /*-->makechar*/
  182. /**********************************************************************/
  183. /****************************** makechar ******************************/
  184. /**********************************************************************/
  185.  
  186. char
  187. makechar(p,mask)
  188. UNSIGN32* p[];
  189. register UNSIGN32 mask;
  190. {
  191.  
  192. }
  193.  
  194. #include "movedown.h"
  195. #include "moveover.h"
  196. #include "moveto.h"
  197. #include "nosignex.h"
  198. #include "openfont.h"
  199. #include "option.h"
  200.  
  201. /*-->outline*/
  202. /**********************************************************************/
  203. /****************************** outline *******************************/
  204. /**********************************************************************/
  205.  
  206.  
  207. void
  208. outline(pline)
  209. char *pline;
  210. {
  211.  
  212. }
  213.  
  214. #include "outrow.h"
  215.  
  216. /*-->prtbmap*/
  217. /**********************************************************************/
  218. /****************************** prtbmap *******************************/
  219. /**********************************************************************/
  220. void prtbmap()
  221. {
  222. }
  223. #include "prtpage.h"
  224. #include "readfont.h"
  225. #include "readgf.h"
  226. #include "readpk.h"
  227. #include "readpost.h"
  228. #include "readpxl.h"
  229. #include "reldfont.h"
  230. #include "rulepxl.h"
  231. #include "setchar.h"
  232. #include "setfntnm.h"
  233. #include "setrule.h"
  234. #include "signex.h"
  235. #include "skgfspec.h"
  236. #include "skipfont.h"
  237. #include "skpkspec.h"
  238. #include "special.h"
  239. #include "strchr.h"
  240. #include "strcm2.h"
  241. #include "strid2.h"
  242. #include "strrchr.h"
  243. #include "tctos.h"
  244. #include "usage.h"
  245. #include "warning.h"
  246.  
  247.  
  248. void
  249. vgainit()        /* initialize device */
  250. {
  251.     union REGS rg;
  252.     char *envptr;
  253.  
  254.     *((unsigned long far *) (0x8c)) = (unsigned long)  exfn;
  255.     /*
  256.      * Oh my! That put a pointer to exfn() in the MS-DOS cntl-break
  257.      * interrupt vector! 
  258.      */
  259.  
  260.     rg.h.ah = 15;
  261.     int86(16,&rg,&rg);
  262.     oldvmode = rg.h.al;
  263.  
  264.     envptr = getenv("DVISCR");
  265.     if(strcmp(envptr,"EGAM") == 0 && envptr != NULL) displaycode = 5;
  266.     else if(strcmp(envptr,"EGAC") == 0 && envptr != NULL) displaycode = 4;
  267.     else if(strcmp(envptr,"VGAM") == 0 && envptr != NULL) displaycode = 7;
  268.     else if(strcmp(envptr,"VGAC") == 0 && envptr != NULL) displaycode = 30;
  269.     else {
  270.  
  271.         rg.x.ax = 0x1a00;
  272.         int86(16,&rg,&rg);
  273.         if(rg.h.al == 0x1a) {
  274.            displaycode = rg.h.bl;
  275.         } else {
  276.            rg.h.ah = 0x12;
  277.            rg.h.bl = 16;
  278.            int86(16,&rg,&rg);
  279.            if(rg.h.bl == 16) {
  280.                displaycode = 0;
  281.            } else {
  282.                if (oldvmode == 7) displaycode = 5;
  283.                else displaycode = 4;
  284.            }
  285.         }
  286.     }
  287.     switch (displaycode) {
  288.        case 4:
  289.            rg.x.ax = 16;
  290.            maxm =  YBIT-350;
  291.            nlines = 350;
  292.            break;
  293.        case 5:
  294.            rg.x.ax = 15;
  295.            maxm =  YBIT-350;
  296.            nlines = 350;
  297.            break;
  298.        case 7:
  299.        case 8:
  300.        case 11:
  301.        case 12:
  302.            rg.x.ax = 17;
  303.            maxm =  YBIT-480;
  304.            nlines = 480;
  305.            break;
  306.        case 30:
  307.            rg.x.ax = 18;
  308.            maxm = YBIT-480;
  309.            nlines = 480;
  310.            break;
  311.        default:
  312.            puts("Invalid display adapter - requires EGA, VGA, or MCGA.");
  313.            exit(1);
  314.     }
  315.     int86(16,&rg,&rg);
  316. }
  317.  
  318.  
  319. void
  320. drawbmap(mline)
  321. int mline;
  322. {
  323.  
  324.     register char *c;            /* pointer into v7[] */
  325.     unsigned char *q;
  326.     unsigned char far *sc;
  327.     register UNSIGN32 mask;        /* mask for single bit selection */
  328.     INT16 i,j,k,ybottom,ytop;
  329.  
  330.     if(first_picture){
  331.         first_picture = FALSE;
  332.         vgainit();
  333.     }
  334.     sc = (unsigned char far *)0xa0000000;
  335.  
  336.     ytop = YBIT-nlines-mline;
  337.     for (i = nlines-1; i >= 0; i--) {
  338.         q = (unsigned char *)BITMAP((ytop+i),0);
  339.         if(reversevideo){
  340.             for (j = 0; j < 80; j += 4, q += 4) {
  341.